sysroot: Add precondition that load() has been called for some API calls
authorColin Walters <walters@verbum.org>
Fri, 15 Aug 2014 19:21:40 +0000 (15:21 -0400)
committerColin Walters <walters@verbum.org>
Fri, 15 Aug 2014 19:21:40 +0000 (15:21 -0400)
We require the caller to invoke load() at the moment to do most
things.

src/libostree/ostree-sysroot.c

index 0c92f26900ac043a7905dedf06a43f4e185016ad..c88c6d425faf5c4ff627f1ea830c083a332be0b8 100644 (file)
@@ -755,6 +755,8 @@ ostree_sysroot_get_subbootversion (OstreeSysroot   *self)
 OstreeDeployment *
 ostree_sysroot_get_booted_deployment (OstreeSysroot       *self)
 {
+  g_return_val_if_fail (self->loaded, NULL);
+
   return self->booted_deployment;
 }
 
@@ -767,8 +769,12 @@ ostree_sysroot_get_booted_deployment (OstreeSysroot       *self)
 GPtrArray *
 ostree_sysroot_get_deployments (OstreeSysroot  *self)
 {
-  GPtrArray *copy = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
+  GPtrArray *copy;
   guint i;
+
+  g_return_val_if_fail (self->loaded, NULL);
+
+  copy = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
   for (i = 0; i < self->deployments->len; i++)
     g_ptr_array_add (copy, g_object_ref (self->deployments->pdata[i]));
   return copy;